package com.design.cjm.structural.composite.example;

import java.util.Objects;

/**
 * @Author: Jie Ming Chen
 * @Date: 2018/9/24
 * @Version 1.0
 */
public abstract class Component {

    protected String name;

    public Component(String name) {

        this.name = name;
    }

    public abstract void add(Component c);

    public abstract void remove(Component c);

    public abstract void display(int depth);

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        Component component = (Component) o;
        return Objects.equals(name, component.name);
    }

    @Override
    public int hashCode() {

        return Objects.hash(name);
    }
}
